/*
 * @Description: 组织机构相关接口
 * @Author: Rfan
 * @Date: 2022-03-15 13:08:28
 * @LastEditTime: 2023-02-27 09:30:02
 */

import { appState } from '@/store/mobx';
import { configRequest } from '@/utils/request';

// 通过单位ID查询组织机构
export function fetchDepartmentListByUnitId(unitId) {
  return configRequest({
    url: `/sys-department/list`,
    method: 'post',
    data: { unitId: appState?.unitId }
  });
}

// 查询全部组织机构列表
export function fetchAllDepartmentList(data) {
  return configRequest({
    url: '/sys-department/list',
    method: 'post',
    data
  });
}

// 增加组织机构
export function addDepartment(data) {
  return configRequest({
    url: '/sys-department/',
    method: 'post',
    data
  });
}

// 增加组织机构
export function editDepartment(data) {
  return configRequest({
    url: '/sys-department/',
    method: 'put',
    data
  });
}

// 删除组织机构
export function deleteDepartment(id) {
  return configRequest({
    url: `/sys-department/${id}`,
    method: 'delete'
  });
}
